package com.jboa.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import com.jboa.dao.IEmployeeDAO;
import com.jboa.vo.SysDepartment;
import com.jboa.vo.SysEmployee;
@Repository("employeeDao")
public class EmployeeDAOImpl extends HibernateDaoSupport implements IEmployeeDAO {

	/**
	 * 根据工号获取员工信息
	 */
	public List<SysEmployee> getByID(SysEmployee employee) {
		return super.getHibernateTemplate().find("from SysEmployee e where e.sn=?",new Object[]{employee.getSn()});
	}

	/**
	 * 保存
	 */
	public void save(SysEmployee employee) {
		super.getHibernateTemplate().save(employee);
		
	}
	
	/**
	 * 根据职位信息和部门获取职员
	 */
	public SysEmployee getByDeptAndPosition(String position, SysDepartment dept) {
		List<SysEmployee> ls=getHibernateTemplate().find("from SysEmployee e where e.sysDepartment.name=? and e.sysPosition.nameCn=?",new Object[]{dept.getName(),position});
		return ls.get(0);
	}
	
}
